package com.likuicat.cataiagentbackend.demo.invoke;

import jakarta.annotation.Resource;
import org.springframework.ai.chat.messages.AssistantMessage;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.ai.chat.prompt.Prompt;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

/**
 * 使用SpringAi 调用
 */
//@Component
public class SpringAiInvoke implements CommandLineRunner {
    @Resource // 通过名称调用
    private ChatModel dashscopeChatModel; // 阿里ai模型，切换时直接改名即可

    @Override
    public void run(String... args) throws Exception {
        AssistantMessage output = dashscopeChatModel.call(new Prompt("你好"))
                .getResult()
                .getOutput();

        System.out.println("Spring AI Response: " + output.getText());
    }
}
